﻿-- =========================================================================================================
-- Author:		MICHAEL RITACCO
-- Copyright:	2010 MEKHANO GROUP LLC
-- Version:		10/02/2010 1.0
-- =========================================================================================================
CREATE PROCEDURE [flcr].[api_device_type_sel_lov]
@DEVICE_TYPE_ID INT = NULL
,@ACTIVE_FLG BIT = NULL
,@DEVICE_TYPE INT = NULL
,@DEVICE_TYPE_GROUP INT = NULL

AS
BEGIN TRY
  
	SELECT	A.[DEVICE_TYPE_ID]
			,A.[DEVICE_TYPE]
			,A.[DEVICE_TYPE_NAME] 
			,A.[DEVICE_TYPE_GROUP]
			,A.[SORT_ORDER]
			,A.[PARENT_ID]
			,B.[DEVICE_TYPE_GROUP_NAME] 
	  FROM	[FLCR].[DEVICE_TYPE] A
	 INNER JOIN [FLCR].[DEVICE_TYPE_GROUP] B
		ON	A.[DEVICE_TYPE_GROUP] = B.[DEVICE_TYPE_GROUP] 
     WHERE	A.[DEVICE_TYPE_ID] = COALESCE(@DEVICE_TYPE_ID,A.[DEVICE_TYPE_ID])
	   AND	A.[ACTIVE_FLG] = COALESCE(@ACTIVE_FLG,A.[ACTIVE_FLG])
	   AND	A.[DEVICE_TYPE_GROUP] = COALESCE(@DEVICE_TYPE_GROUP,A.[DEVICE_TYPE_GROUP])

END TRY
BEGIN CATCH
	EXEC [flcr].[utl_getDBError];
END CATCH
